<?php


namespace app\common\model;

use think\Hook;

class CourseOrder extends BaseModel
{
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function course()
    {
        return $this->hasMany(Course::class)->order(['date asc', 'index asc']);
    }

    public function teacherCourse()
    {
        return $this->hasOne(TeacherCourse::class, 'teacher_course_id', 'teacher_course_id');
    }

    public function refund()
    {
        return $this->belongsTo(CourseRefund::class, 'course_order_id', 'course_order_id');
    }

    public function teacher()
    {
        return $this->hasOne(Teacher::class, 'teacher_id', 'teacher_id')->field('teacher_id, nickname, headeravatar, phone, year');
    }
}